package com.szly.phm.admin.controller;

import com.szly.phm.admin.aspectj.annotation.OperationLogAnnotation;
import com.szly.phm.admin.aspectj.enums.ModuleEnum;
import com.szly.phm.admin.aspectj.enums.OperationActionEnum;
import com.szly.phm.admin.utils.CustomResponse;
import com.szly.phm.admin.utils.SecurityUtils;
import com.szly.phm.common.entity.dto.ra.*;
import com.szly.phm.common.entity.dto.user.LoginUserDTO;
import com.szly.phm.common.entity.result.RootResponse;
import com.szly.phm.common.entity.vo.AreaList;
import com.szly.phm.common.service.IRaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

@RestController
@Validated
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/pc/radar")
@Api(tags = "雷达管理")
public class RaController {
    private final IRaService iRaService;

    @ApiOperation(value = "添加服务区域")
    @OperationLogAnnotation(getModuleName = ModuleEnum.ROLE,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/serverAreas")
    @CustomResponse
    public RootResponse createMajor(@Valid @RequestBody CreateServerAreaDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createServerArea(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询服务区域")
    @GetMapping("/v1/serverAreas")
    @CustomResponse
    public RootResponse selectserverAreas(@Valid ServerAreaPageDTO serverAreaPageDTO) {
        return iRaService.selectserverAreas(serverAreaPageDTO);
    }
    @ApiOperation(value = "删除服务区域")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/serverAreas")
    @CustomResponse
    public RootResponse deleteServerAreas(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteServerAreas(id,userDTO);
    }
    @ApiOperation(value = "修改服务区域")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/serverAreas")
    @CustomResponse
    public RootResponse updateServerAreas(@Valid @RequestBody UpdateServerArea updateServerArea) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateServerAreas(updateServerArea,userDTO);
    }
    @ApiOperation(value = "添加雷达站点")
    @OperationLogAnnotation(getModuleName = ModuleEnum.ROLE,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raStations")
    @CustomResponse
    public RootResponse createRaStations(@Valid @RequestBody CreateRaStationsDTO createRaStationsDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createRaStations(createRaStationsDTO,userDTO);
    }
    @ApiOperation(value = "查询雷达站点")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @GetMapping("/v1/raStations")
    @CustomResponse
    public RootResponse selectRaStations(@Valid RaStationsPageDTO serverAreaPageDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        AreaList areaList = loginUser.getArea().get(0);
        serverAreaPageDTO.setAreaId(
                areaList.getAreaId()
        );
        return iRaService.selectRaStations(serverAreaPageDTO);
    }
    @ApiOperation(value = "删除雷达站点")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raStations")
    @CustomResponse
    public RootResponse deleteRaStations(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaStations(id,userDTO);
    }
    @ApiOperation(value = "修改雷达站点")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raStations")
    @CustomResponse
    public RootResponse updateRaStations(@Valid @RequestBody UpdateRaStations updateServerArea) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateRaStations(updateServerArea,userDTO);
    }
    @ApiOperation(value = "添加服务类型")
    @OperationLogAnnotation(getModuleName = ModuleEnum.ROLE,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raServerTypes")
    @CustomResponse
    public RootResponse createRaServerTypes(@Valid @RequestBody CreateRaServerTypesDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createRaServerTypes(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询服务类型")
    @GetMapping("/v1/raServerTypes")
    @CustomResponse
    public RootResponse selectRaServerTypes(@Valid RaServerTypesPageDTO serverAreaPageDTO) {
        return iRaService.selectRaServerTypes(serverAreaPageDTO);
    }
    @ApiOperation(value = "删除服务类型")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raServerTypes")
    @CustomResponse
    public RootResponse deleteraServerTypes(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaServerTypes(id,userDTO);
    }
    @ApiOperation(value = "修改服务类型")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raServerTypes")
    @CustomResponse
    public RootResponse updateRaServerTypes(@Valid @RequestBody UpdateRaServerTypes updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateRaServerTypes(updateRaServerTypes,userDTO);
    }
    @ApiOperation(value = "添加雷达类型")
    @OperationLogAnnotation(getModuleName = ModuleEnum.ROLE,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/fiRadarTypes")
    @CustomResponse
    public RootResponse createFiRadarTypes(@Valid @RequestBody CreateFiRadarTypesDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createFiRadarTypes(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询雷达类型")
    @GetMapping("/v1/fiRadarTypes")
    @CustomResponse
    public RootResponse selectFiRadarTypes(@Valid FiRadarTypesPageDTO serverAreaPageDTO) {
        return iRaService.selectFiRadarTypes(serverAreaPageDTO);
    }
    @ApiOperation(value = "删除雷达类型")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/fiRadarTypes")
    @CustomResponse
    public RootResponse deleteFiRadarTypes(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteFiRadarTypes(id,userDTO);
    }
    @ApiOperation(value = "修改雷达类型")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/fiRadarTypes")
    @CustomResponse
    public RootResponse updateRaServerTypes(@Valid @RequestBody UpdateFiRardarTypesDTO updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateFiRadarTypes(updateRaServerTypes,userDTO);
    }
    @ApiOperation(value = "添加关重件类型")
    @OperationLogAnnotation(getModuleName = ModuleEnum.ROLE,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raKeyPartsTypes")
    @CustomResponse
    public RootResponse createRaKeyPartsType(@Valid @RequestBody CreateRaKeyPartsTypeDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createRaKeyPartsType(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询关重件类型")
    @GetMapping("/v1/raKeyPartsTypes")
    @CustomResponse
    public RootResponse selectRaKeyPartsType(@Valid RaKeyPartsTypePageDTO serverAreaPageDTO) {
        return iRaService.selectRaKeyPartsType(serverAreaPageDTO);
    }
    @ApiOperation(value = "删除关重件类型")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raKeyPartsTypes")
    @CustomResponse
    public RootResponse deleteRaKeyPartsType(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaKeyPartsType(id,userDTO);
    }
    @ApiOperation(value = "修改关重件类型")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raKeyPartsTypes")
    @CustomResponse
    public RootResponse updateRaKeyPartsType(@Valid @RequestBody UpdateRaKeyPartsTypeDTO updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateRaKeyPartsType(updateRaServerTypes,userDTO);
    }

    @ApiOperation(value = "添加库房信息")
    @OperationLogAnnotation(getModuleName = ModuleEnum.ROLE,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raStorageHomes")
    @CustomResponse
    public RootResponse createRaStorageHomes(@Valid @RequestBody CreateRaStorageHomesDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        if(loginUser.getArea().get(0).getAreaId()==null){
            return RootResponse.error("请先设置当前用户所属区域！！！！");
        }
        userDTO.setAreaId(loginUser.getArea().get(0).getAreaId());
        return iRaService.createRaStorageHomes(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询库房信息")
    @GetMapping("/v1/raStorageHomes")
    @CustomResponse
    public RootResponse selectRaStorageHomes(@Valid RaStorageHomesPageDTO serverAreaPageDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        if(loginUser.getArea().get(0).getAreaId()==null){
            return RootResponse.error("请先设置当前用户所属区域！！！！");
        }
        serverAreaPageDTO.setAreaId(loginUser.getArea().get(0).getAreaId());
        return iRaService.selectRaStorageHomes(serverAreaPageDTO);
    }
    @ApiOperation(value = "删除库房信息")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raStorageHomes")
    @CustomResponse
    public RootResponse deleteRaStorageHomes(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaStorageHomes(id,userDTO);
    }
    @ApiOperation(value = "修改库房信息")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raStorageHomes")
    @CustomResponse
    public RootResponse updateRaStorageHomes(@Valid @RequestBody UpdateRaStorageHomesDTO updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateRaStorageHomes(updateRaServerTypes,userDTO);
    }
    @ApiOperation(value = "添加雷达基础信息")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raRadars")
    @CustomResponse
    public RootResponse createRaRadars(@Valid @RequestBody CreateRaRadarsDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        if(loginUser.getArea().get(0).getAreaId()==null){
            return RootResponse.error("请先设置当前用户所属区域！！！！");
        }
        userDTO.setUsername(loginUser.getUsername());
        userDTO.setAreaId(loginUser.getArea().get(0).getAreaId());
        return iRaService.createRaRadars(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询雷达信息")
    @GetMapping("/v1/raRadars")
    @CustomResponse
    public RootResponse selectRaRadars(@Valid RaRadarsPageDTO serverAreaPageDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        if(loginUser.getArea().get(0).getAreaId()==null){
            return RootResponse.error("请先设置当前用户所属区域！！！！");
        }
        serverAreaPageDTO.setAreaId(loginUser.getArea().get(0).getAreaId());
        return iRaService.selectRaRadars(serverAreaPageDTO);
    }
    @ApiOperation(value = "根据雷达id查询雷达信息")
    @GetMapping("/v1/raRadarsById")
    @CustomResponse
    public RootResponse selectRaRadarsById(@Valid RaRadarsPageDTO serverAreaPageDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        serverAreaPageDTO.setAreaId(loginUser.getArea().get(0).getAreaId());
        return iRaService.selectRaRadarsById(serverAreaPageDTO);
    }

    @ApiOperation(value = "删除雷达信息")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raRadars")
    @CustomResponse
    public RootResponse deleteraRadars(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaRadars(id,userDTO);
    }

    @ApiOperation(value = "修改雷达信息")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raRadars")
    @CustomResponse
    public RootResponse updateRadars(@Valid @RequestBody UpdateRaRadarDTO updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        userDTO.setAreaId(loginUser.getArea().get(0).getAreaId());
        return iRaService.updateRadars(updateRaServerTypes,userDTO);
    }

    @ApiOperation(value = "添加雷达接入方式")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raInterventionTypes")
    @CustomResponse
    public RootResponse createRaInterventionTypes(@Valid @RequestBody CreateRaInterventionTypeDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createRaInterventionTypes(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询雷达接入方式")
    @GetMapping("/v1/raInterventionTypes")
    @CustomResponse
    public RootResponse selectRaInterventionTypes(@Valid RaInterventionTypePageDTO serverAreaPageDTO) {
        return iRaService.selectRaInterventionTypes(serverAreaPageDTO);
    }

    @ApiOperation(value = "删除雷达接入方式")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raInterventionTypes")
    @CustomResponse
    public RootResponse deleteRaInterventionTypes(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id,@NotBlank(message = "radarId不能为空") @RequestParam(value = "radarId") String radarId) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaInterventionTypes(id,radarId,userDTO);
    }
    @ApiOperation(value = "修改雷达接入方式")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raInterventionTypes")
    @CustomResponse
    public RootResponse updateRaInterventionTypes(@Valid @RequestBody UpdateRaInterventionTypeDTO updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateRaInterventionTypes(updateRaServerTypes,userDTO);
    }


    @ApiOperation(value = "添加雷达分系统")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raSystems")
    @CustomResponse
    public RootResponse createRaSystems(@Valid @RequestBody CreateRaSystemsDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createRaSystems(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询雷达分系统")
    @GetMapping("/v1/raSystems")
    @CustomResponse
    public RootResponse selectRaSystems(@Valid RaSystemsPageDTO serverAreaPageDTO) {
        return iRaService.selectRaSystems(serverAreaPageDTO);
    }

    @ApiOperation(value = "删除雷达分系统")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raSystems")
    @CustomResponse
    public RootResponse deleteRaSystems(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaSystems(id,userDTO);
    }

    @ApiOperation(value = "修改雷达分系统")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raSystems")
    @CustomResponse
    public RootResponse updateRaSystems(@Valid @RequestBody UpdateRaSystemsDTO updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateRaSystems(updateRaServerTypes,userDTO);
    }

    @ApiOperation(value = "添加雷达分机")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raExtensions")
    @CustomResponse
    public RootResponse createRaExtensions(@Valid @RequestBody CreateRaExtensionsDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createRaExtensions(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询雷达分机")
    @GetMapping("/v1/raExtensions")
    @CustomResponse
    public RootResponse selectRaExtensions(@Valid RaExtensionsPageDTO serverAreaPageDTO) {
        return iRaService.selectRaExtensions(serverAreaPageDTO);
    }

    @ApiOperation(value = "删除雷达分机")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raExtensions")
    @CustomResponse
    public RootResponse deleteRaExtensions(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaExtensions(id,userDTO);
    }

    @ApiOperation(value = "修改雷达分机")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raExtensions")
    @CustomResponse
    public RootResponse updateRaExtensions(@Valid @RequestBody UpdateRaExtensionsDTO updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateRaExtensions(updateRaServerTypes,userDTO);
    }

    @ApiOperation(value = "添加关重件型号")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raKeyPartsModels")
    @CustomResponse
    public RootResponse createRaKeyPartsModels(@Valid @RequestBody CreateRaKeyPartsModelsDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createRaKeyPartsModels(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询关重件型号")
    @GetMapping("/v1/raKeyPartsModels")
    @CustomResponse
    public RootResponse selectRaKeyPartsModels(@Valid RaKeyPartsModelsPageDTO serverAreaPageDTO) {
        return iRaService.selectRaKeyPartsModels(serverAreaPageDTO);
    }

    @ApiOperation(value = "删除关重件型号")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raKeyPartsModels")
    @CustomResponse
    public RootResponse deleteRaKeyPartsModels(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaKeyPartsModels(id,userDTO);
    }

    @ApiOperation(value = "修改关重件型号")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raKeyPartsModels")
    @CustomResponse
    public RootResponse updateRaKeyPartsModels(@Valid @RequestBody UpdateRaKeyPartsModelsDTO updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateRaKeyPartsModels(updateRaServerTypes,userDTO);
    }

    @ApiOperation(value = "添加库存信息")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raStorages")
    @CustomResponse
    public RootResponse createRaStorages(@Valid @RequestBody CreateRaStoragesDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        userDTO.setAreaId(loginUser.getArea().get(0).getAreaId());
        return iRaService.createRaStorages(createMajorDTO,userDTO);
    }
    @ApiOperation(value = "查询库存信息")
    @GetMapping("/v1/raStorages")
    @CustomResponse
    public RootResponse selectRaStorages(@Valid RaStoragesPageDTO serverAreaPageDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        serverAreaPageDTO.setAreaId(loginUser.getArea().get(0).getAreaId());
        return iRaService.selectRaStorages(serverAreaPageDTO);
    }

    @ApiOperation(value = "删除库存信息")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @DeleteMapping("/v1/raStorages")
    @CustomResponse
    public RootResponse deleteRaStorages(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.deleteRaStorages(id,userDTO);
    }

    @ApiOperation(value = "修改库存信息")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    @PutMapping("/v1/raStorages")
    @CustomResponse
    public RootResponse updateRaStorages(@Valid @RequestBody UpdateRaStoragesDTO updateRaServerTypes) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.updateRaStorages(updateRaServerTypes,userDTO);
    }

    @ApiOperation(value = "查询雷达树")
    @GetMapping("/v1/raTree")
    @CustomResponse
    public RootResponse selectRaTree(@NotBlank(message = "雷达id不能为空") @RequestParam(value = "radarId") String radarId) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.selectRaTree(radarId);
    }
    @ApiOperation(value = "查询未绑定雷达树")
    @GetMapping("/v1/raTreeNoDo")
    @CustomResponse
    public RootResponse selectRaTreeNoDo() {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.selectRaTreeNoDo();
    }
    @ApiOperation(value = "添加雷达树")
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.SAVE)
    @PostMapping("/v1/raTrees")
    @CustomResponse
    public RootResponse createRaTrees(@Valid @RequestBody CreateRaTreesDTO createMajorDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createRaTrees(createMajorDTO,userDTO);
    }

    @ApiOperation(value = "根据雷达id和型号id")
    @GetMapping("/v1/selectRadarIdAndModelId")
    @CustomResponse
    public RootResponse createRaKeyParts(Integer pageNum,Integer pageSize,@NotBlank(message = "雷达id不能为空") @RequestParam(value = "radarId") String radarId,@NotBlank(message = "型号id不能为空") @RequestParam(value = "modelId") String modelId) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.selectRadarIdAndModelId(pageNum,pageSize,radarId,modelId);
    }
    @ApiOperation(value = "关重键设备切换")
    @PostMapping("/v1/keyPartsSwitching")
    @CustomResponse
    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
    public RootResponse createKeyPartsSwitching(@Valid @RequestBody CreateKeyPartsSwitchingDTO createKeyPartsSwitchingDTO) {
        var loginUser = SecurityUtils.getLoginUser();
        var userDTO = new LoginUserDTO();
        userDTO.setUsername(loginUser.getUsername());
        return iRaService.createKeyPartsSwitching(createKeyPartsSwitchingDTO,userDTO);
    }
    @ApiOperation(value = "地址雷达位置")
    @GetMapping("/v1/raStationMap")
    @CustomResponse
    public RootResponse selectRaStationMaps() {
        return iRaService.RaStationMaps();
    }
    @ApiOperation(value = "地址雷达位置状态")
    @GetMapping("/v1/raStationMapStatus")
    @CustomResponse
    public RootResponse selectRaStationMapsStatus() {
        return iRaService.RaStationMapsStatus();
    }
//
//    @ApiOperation(value = "删除关重件信息")
//    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
//    @DeleteMapping("/v1/raKeyParts")
//    public RootResponse deleteRaKeyParts(@NotBlank(message = "Id不能为空") @RequestParam(value = "id") String id) {
//        var loginUser = SecurityUtils.getLoginUser();
//        var userDTO = new LoginUserDTO();
//        userDTO.setUsername(loginUser.getUsername());
//        return iRaService.deleteRaKeyParts(id,userDTO);
//    }
//
//    @ApiOperation(value = "修改关重件信息")
//    @OperationLogAnnotation(getModuleName = ModuleEnum.RADAR,getOperationAction = OperationActionEnum.UPDATE)
//    @PutMapping("/v1/raKeyParts")
//    public RootResponse updateRaKeyParts(@Valid @RequestBody UpdateRaKeyPartsDTO updateRaServerTypes) {
//        var loginUser = SecurityUtils.getLoginUser();
//        var userDTO = new LoginUserDTO();
//        userDTO.setUsername(loginUser.getUsername());
//        return iRaService.updateRaKeyParts(updateRaServerTypes,userDTO);
//    }
}
